<template>
    <div class="teacher">
        <h3>教师姓名：{{ teacher.name }}</h3>
        <h3>教师性别：{{ teacher.sex }}</h3>
        <h3>教师年龄：{{ teacher.age }}</h3>
        <button @click="submit">发送教师姓名给学校父组件</button>
        <button @click="submitToStu">发送教师姓名给学生兄弟组件</button>
    </div>
</template>
<script setup>
import { inject, reactive } from 'vue';


const emits=defineEmits(['get-tname'])

function submit(){
    emits('get-tname',teacher.name)
}
const teacher=reactive({
    name:'李老师',
    sex:'女',
    age:40
})

const $bus=inject('$bus')
function submitToStu(){
    $bus.emit('setTname',teacher.name)
}



</script>